package com.bsy.common.dialog

import android.content.Context
import androidx.core.view.isVisible
import com.bsy.common.R
import com.bsy.common.databinding.DialogConfirmViewBinding
import com.bsy.framework.ext.onClick
import com.lxj.xpopup.core.CenterPopupView

/**
 * Created by Lucy on 2023/10/17.
 * Copyright
 * 描述 :
 */
class ConfirmView(context: Context) : CenterPopupView(context) {
    var confirmListener: OnClickListener? = null
    var cancelListener: OnClickListener? = null
    private var binding: DialogConfirmViewBinding? = null
    var title: String? = "提示"//内容
    var content: String? = ""//内容
    var cancelText: String? ="取消"
    var confirmText: String? = "确定"
    var isHideCancel: Boolean = false
    override fun getImplLayoutId(): Int = R.layout.dialog_confirm_view

    override fun onCreate() {
        super.onCreate()
        binding = DialogConfirmViewBinding.bind(popupImplView)
        binding?.tvConfirm?.onClick {
            confirmListener?.onClick(this)
            dismiss()
        }
        binding?.tvCancel?.onClick {
            cancelListener?.onClick(this)
            dismiss()
        }
        binding?.tvTitle?.text = title
        binding?.tvCancel?.text = cancelText
        binding?.tvConfirm?.text = confirmText
        binding?.tvContent?.text = content
        if (isHideCancel) {
            binding?.tvCancel?.isVisible=false
        }
    }
}